package view;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;

import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;


@SuppressWarnings("serial")
public class DisplaySearchPanel extends JPanel {

	JLabel displayPanelTitle;
	JTextArea displayInformation;
	JScrollPane scrollPane;
	
	public DisplaySearchPanel() {

		setLayout(new GridBagLayout());
		setPreferredSize(new Dimension(ViewConstants.DISPLAY_SEARCH_WIDTH, ViewConstants.DISPLAY_SEARCH_HEIGHT));
		setMinimumSize(new Dimension(ViewConstants.DISPLAY_SEARCH_WIDTH, ViewConstants.DISPLAY_SEARCH_HEIGHT));
		setMaximumSize(new Dimension(ViewConstants.DISPLAY_SEARCH_WIDTH, ViewConstants.DISPLAY_SEARCH_HEIGHT));
		setBackground(new Color(16777215));
		
		GridBagConstraints constraints = new GridBagConstraints();
		constraints.fill = GridBagConstraints.HORIZONTAL;
		
		displayPanelTitle = new JLabel("<html>Informations <br> disponibles :</html>");
		displayPanelTitle.setFont(ViewConstants.chartFont);
		displayPanelTitle.setForeground(ViewConstants.color);
		displayPanelTitle.setBorder(BorderFactory.createLineBorder(Color.black));
		displayPanelTitle.setHorizontalAlignment(JLabel.CENTER);
		displayPanelTitle.setVerticalAlignment(JLabel.CENTER);
		displayPanelTitle.setPreferredSize(new Dimension(ViewConstants.DISPLAY_SEARCH_WIDTH, ViewConstants.SMALL_TITLE_HEIGHT*3/2));
		displayPanelTitle.setMinimumSize(new Dimension(ViewConstants.DISPLAY_SEARCH_WIDTH, ViewConstants.SMALL_TITLE_HEIGHT*3/2));
		displayPanelTitle.setMaximumSize(new Dimension(ViewConstants.DISPLAY_SEARCH_WIDTH, ViewConstants.SMALL_TITLE_HEIGHT*3/2));

		constraints.weighty = 1;
		constraints.insets = new Insets(10,10,10,10);
		constraints.gridx = 0;
		constraints.gridy = 0;
		add(displayPanelTitle,constraints);
		
		displayInformation = new JTextArea();
		displayInformation.setCaretPosition(0);
		displayInformation.setWrapStyleWord(true);
		displayInformation.setLineWrap(true);
		displayInformation.setMinimumSize(new Dimension(ViewConstants.DISPLAY_SEARCH_WIDTH, ViewConstants.DISPLAY_SEARCH_HEIGHT - 100));
		displayInformation.setEditable(false);
		scrollPane = new JScrollPane(displayInformation, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
		scrollPane.setMinimumSize(new Dimension(ViewConstants.DISPLAY_SEARCH_WIDTH, ViewConstants.DISPLAY_SEARCH_HEIGHT - 100));
		constraints.gridx = 0;
		constraints.gridy = 1;
		add(scrollPane,constraints);
	}
	
	public void setText(String text) {
		displayInformation.setText(text);
		displayInformation.setCaretPosition(0);
	}
}
